/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.guet.careapp.pojo;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author LXM
 */
@Entity
@Table(name = "t_company_leagal_people_info")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TCompanyLeagalPeopleInfo.findAll", query = "SELECT t FROM TCompanyLeagalPeopleInfo t"),
    @NamedQuery(name = "TCompanyLeagalPeopleInfo.findByLeagalId", query = "SELECT t FROM TCompanyLeagalPeopleInfo t WHERE t.leagalId = :leagalId"),
    @NamedQuery(name = "TCompanyLeagalPeopleInfo.findByName", query = "SELECT t FROM TCompanyLeagalPeopleInfo t WHERE t.name = :name"),
    @NamedQuery(name = "TCompanyLeagalPeopleInfo.findByIndetifyNum", query = "SELECT t FROM TCompanyLeagalPeopleInfo t WHERE t.indetifyNum = :indetifyNum"),
    @NamedQuery(name = "TCompanyLeagalPeopleInfo.findByPhone", query = "SELECT t FROM TCompanyLeagalPeopleInfo t WHERE t.phone = :phone")})
public class TCompanyLeagalPeopleInfo implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "leagal_id")
    private Integer leagalId;
    @Size(max = 30)
    @Column(name = "name")
    private String name;
    @Size(max = 60)
    @Column(name = "indetify_num")
    private String indetifyNum;
    // @Pattern(regexp="^\\(?(\\d{3})\\)?[- ]?(\\d{3})[- ]?(\\d{4})$", message="电话/传真格式无效, 应为 xxx-xxx-xxxx")//if the field contains phone or fax number consider using this annotation to enforce field validation
    @Size(max = 20)
    @Column(name = "phone")
    private String phone;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "legalInfoId")
    private Collection<TCompanyInfo> tCompanyInfoCollection;
    @JoinColumn(name = "user_info_id", referencedColumnName = "u_id")
    @ManyToOne(optional = false)
    private TUserInfo userInfoId;

    public TCompanyLeagalPeopleInfo() {
    }

    public TCompanyLeagalPeopleInfo(Integer leagalId) {
        this.leagalId = leagalId;
    }

    public Integer getLeagalId() {
        return leagalId;
    }

    public void setLeagalId(Integer leagalId) {
        this.leagalId = leagalId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getIndetifyNum() {
        return indetifyNum;
    }

    public void setIndetifyNum(String indetifyNum) {
        this.indetifyNum = indetifyNum;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    @XmlTransient
    public Collection<TCompanyInfo> getTCompanyInfoCollection() {
        return tCompanyInfoCollection;
    }

    public void setTCompanyInfoCollection(Collection<TCompanyInfo> tCompanyInfoCollection) {
        this.tCompanyInfoCollection = tCompanyInfoCollection;
    }

    public TUserInfo getUserInfoId() {
        return userInfoId;
    }

    public void setUserInfoId(TUserInfo userInfoId) {
        this.userInfoId = userInfoId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (leagalId != null ? leagalId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TCompanyLeagalPeopleInfo)) {
            return false;
        }
        TCompanyLeagalPeopleInfo other = (TCompanyLeagalPeopleInfo) object;
        if ((this.leagalId == null && other.leagalId != null) || (this.leagalId != null && !this.leagalId.equals(other.leagalId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pojo.TCompanyLeagalPeopleInfo[ leagalId=" + leagalId + " ]";
    }
    
}
